package cmd

import (
	"fmt"
	"github.com/spf13/cobra"
	"gitlab-sync/gitlabapi"
)

var (
	usersSyncCmd = &cobra.Command{
		Use:   "user",
		Short: "用户同步 $ gitlab-sync user -d={all}/{username}",
		Long: `用户同步命令:

$ gitlab-sync user -d=all  --同步所有用户
  gitlab-sync user -d={username} --同步指定用户

`,
		Run: func(cmd *cobra.Command, args []string) {
			data := cmd.Flag("d")
			if data != nil {
				gitlabapi.CreateUsers(data.Value.String())
			} else {
				fmt.Println("请输入：gitlab-sync user -d={all}/{username}")
			}
		},
	}
)

func init() {
	usersSyncCmd.Flags().StringP("d", "d", "", "同步类型")
	rootCmd.AddCommand(usersSyncCmd)
}
